import Taro from '@tarojs/taro';
import { View, Image, Button} from '@tarojs/components';
import { connect } from '@tarojs/redux';
import * as detailApi from './service';
import './index.scss';
import { Component } from 'nervjs';
import MySwiper from '../../components/MySwiper';

@connect(({goods}) => ({
    ...goods,
}))
export default class Cart extends Component {

    config = {
        navigationBarTitleText: '',
    };

    componentDidMount() {
        // this.setState({
        //     goodsId: this.props._$router.params.id,
        // })

        // this.getGoodsInfo(this.props._$router.params.id);
    }

    async getGoodsInfo(goodsId) {
        const res = await detailApi.getProductInfo({
            id: goodsId
        });
        if (res.status == 'ok') {
            let imgList;
            if (res.data.image){
                imgList = res.data.images.map((item) => {
                    return {
                        image_src: item,
                    };
                });
            } else {
                imgList = [{
                    image_src: "http://static-r.msparis.com/uploads/d/1/d1ca37e902e5550ad2c82c721bc216ce.png",
                }];
            }
            Taro.setNavigationBarTitle({
                title: res.data.name
            })
            this.setState({
                detail: res.data,
                imageObj: imgList,
            })
        }
    }

    render() {
        const { imageObj, detail } = this.state;
        return (
          <View>123</View>
        );
    }
}